package com.example.day_17.presenter;

import com.example.day_17.bean.BannerBean;
import com.example.day_17.bean.InFoBean;
import com.example.day_17.contract.HomeContract;
import com.example.day_17.model.HomeModel;

public class HomePresenter implements HomeContract.Presenter {

    HomeContract.View homView;
    private final HomeModel homeModel;

    public HomePresenter(HomeContract.View homView) {
        this.homView = homView;
        homeModel = new HomeModel();
    }

    @Override
    public void getBannerData() {
        homeModel.getBannerData(new HomeContract.CallBack() {
            @Override
            public void onSuccessBanner(BannerBean bannerBean) {
                homView.onSuccessBanner(bannerBean);
            }

            @Override
            public void onSuccessList(InFoBean inFoBean) {
            }

            @Override
            public void onFail(String errorMsg) {
                homView.onFail(errorMsg);
            }
        });
    }

    @Override
    public void getListData() {
        homeModel.getListData(new HomeContract.CallBack() {
            @Override
            public void onSuccessBanner(BannerBean bannerBean) {

            }

            @Override
            public void onSuccessList(InFoBean inFoBean) {
                homView.onSuccessList(inFoBean);
            }

            @Override
            public void onFail(String errorMsg) {
                homView.onFail(errorMsg);
            }
        });
    }
}
